This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
require(ggplot2)
## Loading required package: ggplot2
require(ggthemes)
## Loading required package: ggthemes
## Warning: package 'ggthemes' was built under R version 3.1.3
dmm_data <- read.csv('/Users/abhisheksharma/Desktop/R_MoC/data/project.csv')
variables <- read.csv('/Users/abhisheksharma/Desktop/R_MoC/data/variables.csv',header = TRUE)
colnames(dmm_data) <-variables[,2][1:201]
dmm.cols <- colnames(dmm_data)
to_plots<-c("totalspend", "totaltrans", "tf92", "tf68")
dmm.cols <- colnames(dmm_data)
for(i in dmm.cols[2:24]){
title <- paste('Boxplot Of',i)
print(ggplot(dmm_data, aes(y=get(i), x = as.factor(Objective), fill=factor(Objective))) +
geom_boxplot( position="dodge", notch = TRUE) +
scale_x_discrete(labels=c("Non-respondent", "Respondent"),name = 'Objective') +
scale_y_continuous(name=paste(i)) +
ggtitle(title) +
scale_fill_hue(name="Objective",
labels=c("Non-Respondent", "Respondent")) +
theme_economist() +
coord_cartesian(ylim=c(min(dmm_data[,i]) - 0.05 * range(dmm_data[,i]),
max(dmm_data[,i]) + 0.05 * range(dmm_data[,i])))
)
}
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
for(i in dmm.cols[25:201]){
title <- paste('Boxplot Of',variables$Explanation[i == variables$Var.name])
print(ggplot(dmm_data, aes(y=get(i), x = as.factor(Objective), fill=factor(Objective))) +
geom_boxplot( position="dodge", notch = TRUE) +
scale_x_discrete(labels=c("Non-respondent", "Respondent"),name = 'Objective') +
scale_y_continuous(name=paste(i)) +
ggtitle(title) +
scale_fill_hue(name="Objective",
labels=c("Non-Respondent", "Respondent")) +
theme_economist() +
coord_cartesian(ylim=c(min(dmm_data[,i]) - 0.05 * range(dmm_data[,i]),
max(dmm_data[,i]) + 0.05 * range(dmm_data[,i])))
)
}
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.
## notch went outside hinges. Try setting notch=FALSE.